package com.xpec.c4.game.login;

import com.xpec.c4.game.utility.GUID;

public class PlayerLockInfo {
	
	/**
	 * 所以帳號的id	
	 */
	private GUID lockPlayerGuid;
	
	/**
	 * 上一次詢問解鎖的時間 (避免被卡死)
	 */
	private Long lastSendUnlockRequestTime;
	
	/**
	 * client與server連線用
	 */
	private GUID sessionID;
	
	public PlayerLockInfo(){}
	public PlayerLockInfo(GUID lockPlayerGuid , Long lastSendUnlockRequestTime , GUID sessionID){
		this.lockPlayerGuid = lockPlayerGuid;
		this.lastSendUnlockRequestTime = lastSendUnlockRequestTime;
		this.sessionID = sessionID;
	}
	/**
	 * lock時間是否過時
	 */
	public boolean isExpire(){
		if(this.lastSendUnlockRequestTime == null)
			return true;
		else{
			long curTime = System.currentTimeMillis();
			//發送過了30sec都沒回應, 當作過期了
			if( (curTime - lastSendUnlockRequestTime) > 1 * 30* 1000){
				return true;
			}
		}
		return false;
	}
	public GUID getLockPlayerGuid() {
		return lockPlayerGuid;
	}
	public void setLockPlayerGuid(GUID lockPlayerGuid) {
		this.lockPlayerGuid = lockPlayerGuid;
	}
	public Long getLastSendUnlockRequestTime() {
		return lastSendUnlockRequestTime;
	}
	public void setLastSendUnlockRequestTime(Long lastSendUnlockRequestTime) {
		this.lastSendUnlockRequestTime = lastSendUnlockRequestTime;
	}
	public GUID getSessionID() {
		return sessionID;
	}
	public void setSessionID(GUID sessionID) {
		this.sessionID = sessionID;
	}
}
